<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('联系人类别管理')" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css"/>
    <style>
        .container-div {
            padding: 20px;
            background: linear-gradient(135deg, #f5f7fa 0%, #e4e8eb 100%);
            min-height: calc(100vh - 120px);
            border-radius: 10px;
            box-shadow: 0 4px 20px 0 rgba(0, 0, 0, 0.05);
        }

        .search-collapse {
            background: white;
            padding: 20px;
            border-radius: 8px;
            margin-bottom: 20px;
            box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
        }

        .select-list ul {
            display: flex;
            align-items: center;
            flex-wrap: wrap;
            gap: 15px;
            margin: 0;
            padding: 0;
        }

        .select-list li {
            list-style: none;
            display: flex;
            align-items: center;
        }

        .select-list label {
            margin-right: 10px;
            font-weight: 500;
            color: #606266;
            min-width: 80px;
            text-align: right;
        }

        .select-list input {
            border: 1px solid #dcdfe6;
            border-radius: 4px;
            padding: 8px 15px;
            transition: all 0.3s;
            width: 200px;
        }

        .select-list input:focus {
            border-color: #409eff;
            outline: none;
            box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.2);
        }

        #toolbar {
            margin-bottom: 20px;
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
        }

        #toolbar a {
            border-radius: 6px;
            padding: 8px 15px;
            font-weight: 500;
            transition: all 0.3s;
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
            display: flex;
            align-items: center;
            gap: 5px;
        }

        #toolbar a:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        }

        .table-striped {
            background: white;
            border-radius: 8px;
            overflow: hidden;
            box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
        }

        .btn-xs {
            padding: 4px 10px;
            font-size: 12px;
            border-radius: 4px;
            transition: all 0.2s;
        }

        .btn-xs:hover {
            transform: translateY(-1px);
        }

        .card-header {
            background: linear-gradient(90deg, #f8f9fa, #ffffff);
            border-bottom: 1px solid rgba(0, 0, 0, 0.05);
            padding: 15px 20px;
            font-weight: 600;
            color: #333;
        }

        .fade-in {
            animation: fadeIn 0.5s ease-in-out;
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }
    </style>
</head>
<body class="gray-bg">
<div class="container-div animate__animated animate__fadeIn">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <div class="card-header">
                <i class="fa fa-filter"></i> 高级筛选
            </div>
            <form id="formId" class="mt-3">
                <div class="select-list">
                    <ul>
                        <li class="fade-in">
                            <label>分类名称：</label>
                            <input type="text" name="categoryName" placeholder="请输入分类名称"/>
                        </li>
                        <li class="fade-in" style="margin-left: auto;">
                            <a class="btn btn-primary btn-rounded btn-sm btn-shadow" onclick="$.table.search()">
                                <i class="fa fa-search"></i>&nbsp;搜索
                            </a>
                            <a class="btn btn-warning btn-rounded btn-sm btn-shadow" onclick="$.form.reset()">
                                <i class="fa fa-refresh"></i>&nbsp;重置
                            </a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success btn-shadow" onclick="$.operate.add()" shiro:hasPermission="contact:category:add">
                <i class="fa fa-plus"></i> 添加分类
            </a>
            <a class="btn btn-primary single disabled btn-shadow" onclick="$.operate.edit()" shiro:hasPermission="contact:category:edit">
                <i class="fa fa-edit"></i> 修改分类
            </a>
            <a class="btn btn-danger multiple disabled btn-shadow" onclick="$.operate.removeAll()" shiro:hasPermission="contact:category:remove">
                <i class="fa fa-trash"></i> 批量删除
            </a>
            <a class="btn btn-info btn-shadow" onclick="$.table.exportExcel()" shiro:hasPermission="contact:category:export">
                <i class="fa fa-file-excel-o"></i> 导出Excel
            </a>
        </div>

        <div class="col-sm-12 select-table table-striped mt-3">
            <div class="card-header">
                <i class="fa fa-list"></i> 联系人类别列表
            </div>
            <table id="bootstrap-table" class="table-hover"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('contact:category:edit')}]];
    var removeFlag = [[${@permission.hasPermi('contact:category:remove')}]];
    var prefix = ctx + "contact/category";

    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "联系人类别",
            columns: [{
                checkbox: true
            },
            {
                field: 'categoryId',
                title: '分类ID',
                visible: false
            },
            {
                field: 'categoryName',
                title: '分类名称',
                sortable: true
            },
            {
                field: 'userId',
                title: '用户ID',
                visible:false
            },
            {
                field: 'remark',
                title: '备注',
                sortable: true
            },
            {
                title: '操作',
                align: 'center',
                formatter: function(value, row, index) {
                    var actions = [];
                    actions.push('<a class="btn btn-success btn-xs ' + editFlag + ' btn-shadow" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.categoryId + '\')"><i class="fa fa-edit"></i> 编辑</a> ');
                    actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + ' btn-shadow" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.categoryId + '\')"><i class="fa fa-trash"></i> 删除</a>');
                    return actions.join('');
                }
            }]
        };
        $.table.init(options);

        // 添加悬停效果
        $('#bootstrap-table').on('mouseenter', 'tr', function() {
            $(this).css('transform', 'scale(1.01)');
            $(this).css('box-shadow', '0 2px 8px rgba(0,0,0,0.1)');
        }).on('mouseleave', 'tr', function() {
            $(this).css('transform', 'scale(1)');
            $(this).css('box-shadow', 'none');
        });
    });
</script>
</body>
</html>